package com.heys.app;


/**
 * 继承 多态
 * @author 何宜诗
 *
 */
public class App {
	public static void main(String[] args) {
		//多态 凡是父类能够出现的地方 子类一定能出现
		
		//Person pp = new Persion();
		App app = new App();
		Person p = new Student(); //p 是执向子类的指针 俗称引用
		p.setName("huakai");
		app.say(p);
		Person p2 = new Teacher();
		p2.setName("zhang san");
		app.say(p2);
		
		
		//向上转型
		Student s = new Student();
		Person ppp = s;
		
		
		Person p3 = new Student(); 
		//向下转型 需谨慎
		Student pi = (Student) p3;//p3 person
		
	}
	
	public void say(Person p) {
		p.say();
		p.eat();
	}
}
